<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的课程 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            padding-top: 20px;
        }
        .navbar {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .navbar-brand, .navbar-nav > li > a {
            color: white !important;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .course-card {
            background: white;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .course-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        }
        .course-image {
            width: 100%;
            height: 150px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 48px;
            margin-bottom: 15px;
        }
        .course-title {
            font-size: 20px;
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
        }
        .course-info {
            color: #666;
            font-size: 14px;
            margin-bottom: 5px;
        }
        .course-info i {
            margin-right: 5px;
            color: #667eea;
        }
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #999;
        }
        .empty-state i {
            font-size: 64px;
            margin-bottom: 20px;
            color: #ddd;
        }
        .avatar-container {
            display: inline-block;
            margin-right: 10px;
            vertical-align: middle;
        }
        .student-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 2px solid rgba(255,255,255,0.8);
            object-fit: cover;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .student-avatar:hover {
            transform: scale(1.1);
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" th:href="@{/student}" style="display: flex; align-items: center;">
                    <div class="avatar-container">
                        <img th:src="${session.student?.avatar != null and !session.student.avatar.isEmpty() ? '/' + session.student.avatar : ''}" 
                             class="student-avatar"
                             th:onclick="'location.href=\'' + @{/student/settings} + '\''"
                             onerror="if(this.src.indexOf('data:image') === -1) { this.onerror=null; this.src=''; }"
                             alt="头像">
                    </div>
                    <span><i class="fa fa-arrow-left"></i> 返回主页</span>
                </a>
            </div>
            <ul class="nav navbar-nav">
                <li><a th:href="@{/student/courses}">我的课程</a></li>
            </ul>
        </div>
    </nav>
    
    <div class="container">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-book"></i> 我的课程</h3>
            </div>
            <div class="panel-body">
                <div th:if="${#lists.isEmpty(courses)}" class="empty-state">
                    <i class="fa fa-book"></i>
                    <h4>暂无课程</h4>
                    <p>您还没有课程，请联系您的教师添加科目信息</p>
                </div>
                
                <div th:if="${!#lists.isEmpty(courses)}" class="row">
                    <div class="col-md-6" th:each="course : ${courses}">
                        <div class="course-card">
                            <div class="course-image">
                                <i class="fa fa-book"></i>
                            </div>
                            <div class="course-title" th:text="${course.subject}">课程名称</div>
                            <div class="course-info">
                                <i class="fa fa-user"></i>
                                <span>教师：<strong th:text="${course.teacherName}">教师姓名</strong></span>
                            </div>
                            <div class="course-info">
                                <i class="fa fa-building"></i>
                                <span>学院：<span th:text="${course.college}">学院名称</span></span>
                            </div>
                            <div class="course-info">
                                <i class="fa fa-users"></i>
                                <span>班级：<span th:text="${course.className}">班级名称</span></span>
                            </div>
                            <div class="course-info" th:if="${course.major != null and !course.major.isEmpty()}">
                                <i class="fa fa-graduation-cap"></i>
                                <span>专业：<span th:text="${course.major}">专业名称</span></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

